package com.example.server.controller;

import com.example.server.mapper.entity.User;
import com.example.server.service.UserService;
import com.example.server.service.commands.RegisterCommand;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("users")
public class UserController {
    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping
    public List<User> getList() {
        return userService.getList();
    }

    @PostMapping
    public void register(@RequestBody RegisterCommand registerCommand) {
        userService.create(registerCommand);
    }

}
